package cn.tude.websocket.base.config.response;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

@NoArgsConstructor
@AllArgsConstructor
@Getter
public class JsonResult {

    private Integer code;
    private String msg;
    private Object data;

    public JsonResult(StatusCode sc, Object data) {
        this.code = sc.getCode();
        this.msg = sc.getMsg();
        this.data = data;
    }

    public JsonResult(StatusCode sc) {
        this.code = sc.getCode();
        this.msg = sc.getMsg();
    }

    public static JsonResult ok(Object data) {
        return new JsonResult(StatusCode.OPERATION_SUCCESS, data);
    }

    public static JsonResult ok() {
        return JsonResult.ok(null);
    }

}
